package com.shell.arouter.demo.paint

import android.content.Context
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.durian.base.frame.viewbinding.viewBindings
import com.durian.ui.dialog.NiceDialogFragment
import com.henanjianye.soon.communityo2o2.databinding.FragmentDiyViewBinding
import com.henanjianye.soon.communityo2o2.databinding.FragmentPaintBinding
import com.shell.arouter.extend.PATH_FRAGMENT_PAINT
import com.shell.arouter.extend.toast
import com.shell.arouter.ui.FragmentCommon

/**
 * 说明：FragmentGson
 * <p/>
 * 作者：Fanly
 * <p/>
 * 类型：Class
 * <p/>
 * 时间：2020/04/25 21:38
 * <p/>
 * 版本：version 1.0
 */
@Route(path = PATH_FRAGMENT_PAINT)
class FragmentPaint : FragmentCommon() {

    private val viewBinding by viewBindings<FragmentPaintBinding>()
    var byte : ByteArray? = ByteArray(100*1024*1024)

    override fun bindRootView(context: Context?): View {
        return viewBinding.root
    }

    override fun isShowTitleBar(): Boolean {
        return true
    }

    override fun isShowTitleBarBack(): Boolean {
        return true
    }

    override fun bindTitleBarText(): String {
        return "Paint应用"
    }

    override fun onFirstUserVisible() {
        super.onFirstUserVisible()
        viewBinding.btnDialog.setOnClickListener {
            showDialog()
            showDialog()
        }
    }

    private fun showDialog(){
        NiceDialogFragment<FragmentDiyViewBinding>()
            .layout(FragmentDiyViewBinding::class.java)
            .config {
                it.showBottom = true
            }
            .dismissListener {
                "关闭".toast()
            }
            .bind { fragmentDiyViewBinding, niceDialogFragment ->

            }
            .show(this)
    }

    override fun onDestroyView() {
        super.onDestroyView()
        byte = null
    }
}